package com.kata.chapter12;

/**
 * 执行类
 * Created by Solidsnake on 2014/12/4.
 */
public class Main {

    public static void main(String[] args) {
        MySqlConnection mySqlConnection = new MySqlConnection();
        PostgreSqlConnection postgreSqlConnection = new PostgreSqlConnection();

        System.out.println("使用MySql Log 事务模式");
        Transaction transaction = new LogTransaction(mySqlConnection);
        transaction.runingTransaction();

        System.out.println("\r\n使用PostgreSqll Log 事务模式");
        transaction = new LogTransaction(postgreSqlConnection);
        transaction.runingTransaction();

        System.out.println("\r\n使用PostgreSql 自动关闭连接模式");
        transaction = new AutoCloseTransaction(postgreSqlConnection);
        transaction.runingTransaction();

        System.out.println("\r\n使用MySql 自动关闭连接模式");
        transaction = new AutoCloseTransaction(mySqlConnection);
        transaction.runingTransaction();

        System.out.println("\r\n使用MySql 异常回滚模式");
        transaction = new ExceptionRollBackTransaction(mySqlConnection);
        transaction.runingTransaction();

        System.out.println("\r\nPostgreSql 异常回滚模式");
        transaction = new ExceptionRollBackTransaction(postgreSqlConnection);
        transaction.runingTransaction();

    }
}
